<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>编辑员工</title>
    <script src="__INDEX__/store/js/mui.min.js"></script>
	<link href="__INDEX__/store/css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" href="__INDEX__/store/css/style.css" />
	<link rel="stylesheet" href="__INDEX__/store/css/iconfont.css" />
	<link rel="stylesheet" href="__INDEX__/store/css/sjhout.css" />
	<link rel="stylesheet" href="__INDEX__/store/css/wallet.css" />
	<link rel="stylesheet" href="__INDEX__/store/css/css.css" /> 
	  
    <script type="text/javascript" charset="utf-8">
      	mui.init();
    </script>
</head>
<body>
	<header class="mui-bar mui-bar-nav">
	    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	    <h1 class="mui-title">编辑员工</h1>
	    <a class="mui-pull-right add" >删除</a>
	</header>
	<div class="mui-content recharge_content" style="height: auto;">
		<ul class="myshop_lsdedit alliance_edit">
			<li class="clearfix">
				<div class="left">员工号</div>
				<input class="right clearfix" type="text" placeholder="填写员工号" value="{$clerk_info['no']}" name='no' id='no'>
			</li>
			<li class="clearfix">
				<div class="left">账号</div>
				<input class="right clearfix" type="text" value="{$clerk_info['mobile']}" placeholder="填写登录账号" name='mobile' id='mobile'>
			</li>
			<li class="mui-table-view-cell">
				<div class="left">门店：</div>
				<select name='chain_id' id='chain_id' value="{$clerk_info['chain_id']}">
					{volist name="$agent_store" id="ad" empty=""}
						{if $clerk_info['chain_id'] == $ad.id}
							<option value="{$ad.id}">{$ad.store_name}</option>
						{/if}
					{/volist}
					{volist name="$agent_store" id="ad" empty=""}
						{if $clerk_info['chain_id'] != $ad.id}
							<option value="{$ad.id}">{$ad.store_name}</option>
						{/if}
					{/volist}
				</select>
			</li>
			<li class="mui-table-view-cell">
				<div class="left">职位</div>
				<select name='z_id' id='z_id' value="{$clerk_info['ctype']}">
					{if $clerk_info['ctype'] == 1}
						<option value="1">收银员</option>
						<option value="2">店长</option>
					{else}
						<option value="2">店长</option>
						<option value="1">收银员</option>
					{/if}
				</select>
			</li>
			<li class="clearfix">
				<div class="left">姓名</div>
				<input class="right clearfix" value="{$clerk_info['name']}" type="text" placeholder="填写真实姓名" name='name' id='name'>
			</li>
		</ul>
		<button id='create_emp' class="chongz_btn">确定</button>	
	</div>
</body>
</html>
<script type="text/javascript" src="__INDEX__/store/js/jquery.min.js"></script>
<script type="text/javascript" src="__INDEX__/store/js/castapp.js"></script>
<script type="text/javascript" src="__INDEX__/store/js/layer/layer.min.js"></script>
<script type="text/javascript" src="__INDEX__/store/js/picker.js"></script>
<script type="text/javascript" src="__INDEX__/store/js/city.data-3.js"></script>
<script type="text/javascript" src="__INDEX__/store/js/bootstrap.min.js"></script>
<script type="text/javascript" src="__INDEX__/store/js/app.js"></script>
<script>
	$('#create_emp').click(function(){
		//员工号
		var no = $("#no").val();
		//所属门店
		var chain_id = $("#chain_id").val();
		//职位
		var z_id = $("#z_id").val();
		//姓名
		var name = $("#name").val();
		//手机号
		var mobile = $("#mobile").val();
		var myreg = /^1[3578]\d{9}$/; 
		if(name=="" || mobile=="" || no==""){
			$("#create_emp").attr('disabled',false);
			layer.msg('请把信息填写完整');
			return false;
		}
		 if(!myreg.test(mobile)){
		 	$("#create_emp").attr('disabled',false);
	    	layer.msg('请输入有效的手机号码！'); 
	    	return false;
	    }
		
		$.ajax({
			type:'post',
			url: "{:url('agent/edite_emp')}",
			data: {
				no			: no,
				chain_id	: chain_id,
				z_id		: z_id,
				name		: name,
				mobile		: mobile,
				emp_id		: "{$clerk_info['id']}"
			},
			success: function(data) {
				if(data.code == 200) {
					layer.msg(data.msg, {
						  time: 2000 
						}, function(){
							location.href="{:url('agent/employeemage')}";
						});
				}else{
					layer.msg(data.msg);
				}
			}
		});
	});
	
	//删除员工
	$('.add').click(function(){
		$.ajax({
		url: "{:url('agent/del_emp')}",
		data: {
			emp_id: "{$clerk_info['id']}"
		},
		success: function(data) {
			if(data.code == 200) {
					layer.msg(data.msg, {
						  time: 2000 
						}, function(){
							location.href="{:url('agent/employeemage')}";
						});
				}else{
					layer.msg(data.msg);
				}
		}
		});	
	})
</script>